package com.example.controller;

import com.example.model.Product;
import com.example.model.User;
import com.example.service.ProductService;
import com.example.utils.RestResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "product", produces = MediaType.APPLICATION_JSON_VALUE)
public class ProductController {
    @Autowired
    ProductService productService;

    @RequestMapping(value = "getById", method = RequestMethod.GET)
    public RestResult getById(@RequestParam String id) {

        Product product = productService.getById(id);
        return RestResult.ok(product);
    }

    @GetMapping("getById/{id}")
    public RestResult getById(@PathVariable("id") Integer id) {
        Product product = productService.getById(id);
        return RestResult.ok(product);
    }

}
